OpenRoads Designer CONNECT Edition SDK Help

Copy cells from one library to other

The below code snippet shows how to copy cells to new file. It gets the list of all cell libraries and copies the cells from first library to new cell library file(.cel)


using System.IO;
using Bentley.DgnPlatformNET;
using Bentley.MstnPlatformNET;

public void CopyCellsFromOneLibraryToOther()
        {
            // Get list of all cell libaries, and copy the cells from first cell library into new cell library file(.cel) 
            DgnFile dgnFile = Session.Instance.GetActiveDgnFile();

            string cellLibraryPath = "C:\\ProgramData\\Bentley\\OpenRoads Designer CE 10.12\\Configuration\\Organization-Civil\\_Civil Default Standards - Imperial\\Cell";
            DirectoryInfo directoryInfo = new DirectoryInfo(cellLibraryPath);
            FileInfo[] cellFiles = directoryInfo.GetFiles("*.cel");

            foreach (FileInfo cell in cellFiles)
            {
                //Copy first library to new "SampleCopyCells.cel" file
                FileInfo copiedFileInfo = cell.CopyTo(cellLibraryPath + "\\" + "SampleCopyCells.cel", false);
                break;
            }
        }

Here the cells are copied to "SampleCopyCells.cel" file.